﻿using University.Workshop.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Data;
using University.Workshop.Model;

namespace University.Workshop.Tests
{
    
    

    [TestClass()]
    public class DataAccessPurchaseTest
    {


        private TestContext testContextInstance;

          public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        [TestMethod()]
        public void GetPurchaseCodeTest()
        {
            DataTable expected = null;      
            DataTable actual;
            actual = DataAccessPurchase.GetPurchaseCode();
            Assert.AreNotEqual(expected, actual);
        }


        [TestMethod()]
        public void PurchaseDetailRegisterTest()
        {
            PurchaseDetail purchaseDetail = new PurchaseDetail();
            purchaseDetail.CodeProduct = "med001";
            purchaseDetail.CodePurchase = "999999";
            purchaseDetail.Quantity = 0;
            purchaseDetail.TotalPrice = 0;
            purchaseDetail.UnitPrice = 0;
            bool expected = true; 
            bool actual;
            actual = DataAccessPurchase.PurchaseDetailRegister(purchaseDetail);
            DataAccessPurchase.PurchaseDetailDelete(purchaseDetail);
            Assert.AreEqual(expected, actual);
           
        }

        [TestMethod()]
        public void PurchaseRegisterTest()
        {
            Purchase purchase = new Purchase();
            purchase.Code="999";
            purchase.DatePurchase=DateTime.Now;
            purchase.ProviderCode="0";
            purchase.TotalAmount="0";
            purchase.UserCode="1";
            bool expected = true;
            bool actual;
            actual = DataAccessPurchase.PurchaseRegister(purchase);
            DataAccessPurchase.PurchaseDelete(purchase);
            Assert.AreEqual(expected, actual);
        }

        
   
    }
}
